package ArraysDemo;

import java.util.Arrays;
import java.util.Comparator;

public class arraydemo {
    public static void main(String[] args) {

        Stu[] students = new Stu[4];
        students[0] = new Stu("yyx", 20, 100);
        students[1] = new Stu("yyy", 23, 99);
        students[2] = new Stu("xxx", 18, 70);
        students[3] = new Stu("xxy", 29, 80);

        // 匿名内部类
        Arrays.sort(students, new Comparator<Stu>() {
            @Override
            public int compare(Stu o1, Stu o2) {
                return Double.compare(o1.getScore(), o2.getScore());
            }
        });

        System.out.println(Arrays.toString(students));
    }
}
